package work812;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

public class work2 {
  public static void main(String[] args) {
    boolean pd = false;
    Scanner sc = new Scanner(System.in);
    FileReader fr = null;
    BufferedReader br = null;
    try {
      File f = new File("E:\\bdqn\\javaDemo\\worldcup.txt");
      if (!f.exists()) {
        f.createNewFile();
      }
      fr = new FileReader(f);
      br = new BufferedReader(fr);
      String[] strings = new String[5];
      String line;
      int i = 0;
      while ((line = br.readLine()) != null) {
        strings[i] = line;
        i++;
      }
      System.out.println("请输入年份：");
      String year = sc.next();
      for (int j = 0; j < i; j++) {
        if (strings[j].contains(year)) {
          System.out.println(strings[j].substring(strings[j].indexOf("/") + 1, strings[j].length()));
          pd = true;
        }
      }
      if (!pd) {
        System.out.println("没有举办世界杯");
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        br.close();
        fr.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }


  }
}
